import { registerClass } from "../../../cfw/tools/class_decorator";
import BaseNativeAd from "../../core/ad/BaseNativeAd";
import OppoNativeAdItemModel from "../oppo/OppoNativeAdItemModel";
;

@registerClass('MiMoNativeAd')
export default class MiMoNativeAd extends BaseNativeAd {
    open(): void {
    }
    protected instances: { [key: string]: any } = []
    getItemModel() {
        return new OppoNativeAdItemModel()
    }

    create() {
        console.log(" OppoNativeAd create", this.adUnitID)
        this.ad = this.instances[this.adUnitID]
        if (!this.ad) {
            this.ad = this.sdk.createNativeAd({
                adUnitId: this.adUnitID,
            });
            this.ad.onLoad(this.getFunc(this.onLoad))
            this.ad.onError(this.getFunc(this.onError))
            this.instances[this.adUnitID] = this.ad
        }
    }

    destroy(): void {
        if (this.ad) {
            this.ad.offLoad(this.getFunc(this.onLoad))
            this.ad.offError(this.getFunc(this.onError))
            this.ad.destroy()
            this.ad = null;
        }
    }
}